﻿<?php
class Model_Supplier extends Zend_Db_Table_Abstract
{
	protected $_name = 'supplier';

	public function createSupplier ($s_ten,$s_diachi,$s_link,$s_anh)
	{
		$rowSup= $this->createRow();
		if ($rowSup) {
			// update the row values
			$rowSup->s_ten = $s_ten;
			$rowSup->s_diachi = $s_diachi;
			$rowSup->s_link = $s_link;
			$rowSup->s_anh = $s_anh;				
			$rowSup->save();
			//return the new sup
			return $rowSup;
		} else {
			throw new Zend_Exception("Không thể tạo nhà cung cấp mới");
		}
	}
		
	public static function getSupplier()
	{
		$supModel = new self();
		$select = $supModel->select();
		$select->order(array('s_id'));	
		return $supModel->fetchAll($select);
	}
	public static function getSupplierById($sid)
	{
		$supModel = new self();
		$select = $supModel->select();
		$select->order(array('s_id'))
				->where('s_id =?',$sid);			
		return $supModel->fetchAll($select);
	}
	public static function getSupplierLimit($start,$count)
	{
		$supModel = new self();
		$select = $supModel->select();
		$select->order(array('s_id'))
			   ->limit($start,$count);	
		return $supModel->fetchAll($select);
	}
	
}